<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>景区审核</title>
    <!--引入vue.js库-->
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> -->
    <script src="/js/vue.js"></script>
    <!-- element-ui引入样式 -->
    <link rel="stylesheet" href="/css/index.css">
    <!-- element-ui引入组件库 -->
    <script src="/js/index.js"></script>
    <!--引入axios库-->
    <!-- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>-->
    <script src="/js/axios.min.js"></script>
</head>
<body>
<div id="app">
    <el-row style="margin-top: 30px;">
        <el-col :span="4">
            <div class="grid-content bg-purple">
                <el-input v-model="searchForm.name" placeholder="请输入景点名称"></el-input>
            </div>
        </el-col>
        <el-col :span="0.5">
            <div class="grid-content bg-purple-light">
                &nbsp;&nbsp;&nbsp;
            </div>
        </el-col>
        <el-col :span="4">
            <div class="grid-content bg-purple-light">
                <!--                    <el-input v-model="searchForm.summary" placeholder="请输入简述"></el-input>-->


                <template>
                    <el-select v-model="searchForm.isline" placeholder="是否审核">
                        <el-option
                                v-for="item in options"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                        </el-option>
                    </el-select>
                </template>

            </div>
        </el-col>
        <el-col :span="0.5">
            <div class="grid-content bg-purple-light">
                &nbsp;&nbsp;&nbsp;
            </div>
        </el-col>
        <el-col :span="2">
            <div class="grid-content bg-purple">
                <el-button type="primary" @click="search">搜索</el-button>
            </div>
        </el-col>
        <el-col :span="2">
            <el-button type="primary" icon="el-icon-refresh"  @click="refresh">刷新</el-button>
        </el-col>
        <!--            <el-col :span="1">-->
        <!--                <div class="grid-content bg-purple">-->
        <!--                    <el-button type="primary" @click="add() ">添加</el-button>-->
        <!--                </div>-->
        <!--            </el-col>-->
    </el-row>

    <el-table
            :data="tableData"
            style="width: 100%;margin-top: 20px;"
            :row-class-name="tableRowClassName">

<!--        <el-table-column-->
<!--                type="index"-->
<!--                width="80">-->
<!--        </el-table-column>-->

        <el-table-column
                prop="name"
                width="180"
                label="景区名称">
        </el-table-column>

        <el-table-column width="180"
                         prop="themeName"
                         label="主题分类">
        </el-table-column>
        <el-table-column width="180"
                         prop="isline"
                         label="是否审核"
                         :formatter="isTodayShow"
        >
        </el-table-column>
        <el-table-column width="180"
                         prop="scover"
                         label="景区封面">

            <template scope="scope">
                <el-image
                        style="width: 100px; height: 50px"
                        :src="scope.row.scover"
                        :fit="fit"></el-image>
            </template>

        </el-table-column>


        <el-table-column
                width="180"
                prop="jbcode"
                label="景区级别">
        </el-table-column>
        <el-table-column
                prop="yytime" width="180"
                label="营业时间">
        </el-table-column>

        <el-table-column
                prop="saddress" width="180"
                label="景区地址">
        </el-table-column>

        <el-table-column
                prop="taddress" width="180"
                label="购票地址">
        </el-table-column>

        <el-table-column
                prop="mobile" width="180"
                label="手机">
        </el-table-column>

        <el-table-column width="180"
                         prop="summary"
                         label="景区简介">

            <template scope="scope">
                <el-tooltip placement="top">
                    <div slot="content" style="width: 150px;">{{scope.row.summary}}</div>
                    <el-button>查看</el-button>
                </el-tooltip>
            </template>

        </el-table-column>


        <el-table-column width="180"
                         prop="sintroduction"
                         label="景点介绍">

            <template scope="scope">
                <el-tooltip placement="top">
                    <div slot="content" style="width: 150px;">{{scope.row.sintroduction}}</div>
                    <el-button>查看</el-button>
                </el-tooltip>
            </template>

        </el-table-column>


        <el-table-column label="操作" fixed="right" width="150">
            <template slot-scope="scope">
                <!--                <el-button-->
                <!--                        size="mini"-->
                <!--                        @click="handleEdit(scope.$index, scope.row)">查看审核-->
                <!--                </el-button>-->
                <el-button
                        type="success"
                        @click="handleDelete(scope.$index, scope.row)">开始审核
                </el-button>
            </template>
        </el-table-column>
    </el-table>
    <el-pagination
            style="width: 100%;margin-top: 20px;"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
    </el-pagination>
    <!--    添加
        <el-dialog :title="title" :visible.sync="dialogFormVisible">
            <el-form :model="form">

                <el-form-item label="uuid" :label-width="formLabelWidth">
                    <el-input v-model="form.scenicid" autocomplete="off"></el-input>
                </el-form-item>

                <el-form-item label="代码" :label-width="formLabelWidth">
                    <el-input v-model="form.code" autocomplete="off"></el-input>
                </el-form-item>

                <el-form-item label="景区名称" :label-width="formLabelWidth">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
                </el-form-item>

                <el-form-item label="封面" :label-width="formLabelWidth">
                    <el-input v-model="form.scover" autocomplete="off"></el-input>

                    <template scope="scope">
                        <el-image
                                style="width: 100px; height: 50px"
                                :src="scope.row.scover"
                                :fit="fit"></el-image>
                    </template>

                </el-form-item>

                <el-form-item label="景区级别code" :label-width="formLabelWidth">
                    <el-input v-model="form.jbcode" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="营业时间" :label-width="formLabelWidth">
                    <el-input v-model="form.yytime" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="地域code" :label-width="formLabelWidth">
                    <el-input v-model="form.areacode" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="景点简介" :label-width="formLabelWidth">
                    <el-input v-model="form.summary" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="附件存储" :label-width="formLabelWidth">
                    <el-input v-model="form.sintroduction" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="交通指南" :label-width="formLabelWidth">
                    <el-input v-model="form.straffic" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="是否上线" :label-width="formLabelWidth">
                    <el-input v-model="form.isline" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="推荐度" :label-width="formLabelWidth">
                    <el-input v-model="form.weight" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="是否web显示" :label-width="formLabelWidth">
                    <el-input v-model="form.istodayshow" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="成功售出门票数" :label-width="formLabelWidth">
                    <el-input v-model="form.snums" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="已下单门票数" :label-width="formLabelWidth">
                    <el-input v-model="form.onums" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="变更人id" :label-width="formLabelWidth">
                    <el-input v-model="form.bgrid" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="审核状态" :label-width="formLabelWidth">
                    <el-input v-model="form.shstate" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="addUser()">通 过</el-button>
            </div>
        </el-dialog>-->
</div>
<script>
    let vue = new Vue({
        el: '#app',
        data() {
            return {
                tableData: [],
                currentPage: 1,
                pageSize: 5,
                total: 100,
                searchForm: {},
                dialogFormVisible: false,
                title: "添加",
                form: {},
                formLabelWidth: '120px',
                options: [{//下拉菜单的对象
                    value: '',
                    label: '无'
                }, {
                    value: '0',
                    label: '未审核'
                }, {
                    value: '1',
                    label: '已审核'
                }],
            }
        },
        created: function () {//页面初始化时,需要执行的业务可以放入该方法

            this.loadData();
        },
        methods: {//存放所有使用的方法
            loadData() {
                let _this = this;
                //使用axios向后台发请求
                axios.post('/tmscenic/page',
                    {
                        "pageNo": this.currentPage, "pageSize": this.pageSize,
                        "data": {"name": this.searchForm.name, "isline": this.searchForm.isline}
                    })
                    .then(function (response) {
                        if (response.data.code == 200) {
                            _this.tableData = response.data.data.list;
                            _this.total = response.data.data.total;
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
                this.pageSize = val;
                this.loadData();
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
                this.currentPage = val;
                this.loadData();
            },
            //更新
            handleEdit(index, row) {
                console.log(index, row);
                this.dialogFormVisible = true;
                this.title = "更新";
                this.form = row;
            },
            //添加
            add() {
                this.dialogFormVisible = true;
                this.title = "添加";
                this.form = {};
            },
            //添加更新
            addUser() {
                let _this = this;
                let uri = "/tmscenic/add";
                if (this.title == "更新") {
                    uri = "/tmscenic/update"
                }
                //使用axios向后台发请求
                axios.post(uri,
                    this.form)
                    .then(function (response) {
                        if (response.data.code == 200) {
                            _this.$message({
                                message: '成功',
                                type: 'success'
                            });
                            _this.dialogFormVisible = false;
                            _this.loadData();
                        }
                    })
                    .catch(function (error) {
                        _this.$message.error('错误');
                    });
            },
            //授权
            handleDelete(index, row) {
                let _this = this
                this.$confirm('确认通过审核吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    let _this = this
                    axios.post("/tmscenic/update", row)
                        .then(function (response) {
                            if (response.data.code == 200) {
                                _this.loadData();
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: '授权失败'
                                });
                            }
                        })
                    this.$message({
                        type: 'success',
                        message: '授权成功'
                    });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '取消审核'
                    });
                });
            },
            //刷新
            refresh() {
                //原始js重新请求
                location.reload();
            },
            //搜索方法
            search() {
                this.currentPage = 1;
                this.loadData();
            },
            isTodayShow(row, column, cellValue, index) {
                var returnValue = '';
                if (cellValue == '0') {
                    returnValue = "未审核";
                } else {
                    returnValue = "已审核";
                }
                return returnValue;
            },
        }
    })
</script>
</body>
</html>